﻿Imports System.ComponentModel

<DefaultEvent("ConnectionStringChanged")> _
Public Class SqlConnectionStringBuilder

    Private iConnectionString As String = ""
    Public Event ConnectionStringChanged(sender As Object, e As System.EventArgs)

    Public Property ConnectionString As String
        Get
            Return Me.iConnectionString
        End Get
        Set(value As String)
            Me.iConnectionString = value
            Me.ConnectionString_TextBox.Text = Me.iConnectionString
        End Set
    End Property

    Private Sub ConnectionString_Button_Click(sender As System.Object, e As System.EventArgs) Handles ConnectionString_Button.Click
        Dim DLG As SQL_Connection_Dialog = New SQL_Connection_Dialog
        DLG.ConnectionString = Me.iConnectionString
        If DLG.ShowDialog() = Windows.Forms.DialogResult.OK Then
            Me.iConnectionString = DLG.ConnectionString
            Me.ConnectionString_TextBox.Text = Me.iConnectionString
            RaiseEvent ConnectionStringChanged(Me, New EventArgs)
        End If
    End Sub

    Private Sub SqlConnectionStringBuilder_Resize(sender As Object, e As System.EventArgs) Handles Me.Resize

        Me.ConnectionString_TextBox.Location = New Drawing.Point(0, 0)
        Me.ConnectionString_TextBox.Size = New Drawing.Size(Me.Size.Width - 29, 20)
        Me.ConnectionString_Button.Location = New Drawing.Point(Me.Size.Width - 25, 0)
        Me.ConnectionString_Button.Size = New Drawing.Size(25, 20)

    End Sub

    Private Sub ConnectionString_TextBox_TextChanged(sender As System.Object, e As System.EventArgs) Handles ConnectionString_TextBox.TextChanged
        Me.iConnectionString = Me.ConnectionString_TextBox.Text
    End Sub


End Class
